#include <bits/stdc++.h>
using namespace std;

int area[100][2] = {0};

int main() {
	int l, m, sum = 0;
	cin >> l >> m;
	int *ber = (int *)malloc(sizeof(int) * (l + 1));
	for (int i = 0; i <= l; ++i) {
		ber[i] = 1;
	}
	for (int i = 0; i < m; ++i) {
		cin >> area[i][0] >> area[i][1];
		for (int j = area[i][0]; j <= area[i][1]; ++j) {
			ber[j] = 0;
		}
	}
	for (int i = 0; i <= l; ++i) {
		if (ber[i] == 1) {
			sum++;
		}
	}
	cout << sum;
	return 0;
}